<template>
	<el-dialog 
		title="审核" 
		:visible.sync="auditTaskShow"
		@close="$emit('update:auditTaskDialogShow',false)"
		width="50%"
		:append-to-body='true'
		center
		>
		<!--{{getPlanData}}-->
		<el-row>
			<span>审核：</span>
			 <el-select v-model="selectValue" placeholder="请选择" size="mini">
			    <!--<el-option
			      v-for="item in options"
			      :key="item.value"
			      :label="item.label"
			      :value="item.value">
			    </el-option>-->
			    <el-option label="同意" :value="true"></el-option>
			    <el-option label="驳回" :value="false"></el-option>
			  </el-select>
		</el-row>
		<el-row v-if="!selectValue">
			<h4 style="padding:10px 0;">审核意见:</h4>
			<el-input
			  type="textarea"
			  :rows="2"
			  size="mini"
			  placeholder="请输入内容"
			  v-model="remark">
			</el-input>
		</el-row>
		  <span slot="footer" class="dialog-footer">
		    <el-button @click="$emit('update:auditTaskDialogShow',false)" size="mini">取 消</el-button>
		    <el-button type="primary" @click="submitClick" size="mini">确 定</el-button>
		  </span>
	</el-dialog>
</template>

<script>
	export default{
		props:['auditTaskDialogShow','getPlanData'],
		data(){
			return {
				selectValue:true,
				remark:	''	
			}
		},
		methods:{
			submitClick(){
				let params,msg;
				if(this.selectValue){
						 params = {id:this.getPlanData.id,result:this.selectValue}
						 msg = '审核通过！'
				}else{
          if(this.remark == null || this.remark == undefined || this.remark == ""){
            this.$notify({
            	 showClose: true,
            	message: '请输入驳回意见!',
            	type: 'warning',
            	title:"成功"
            })
            return;
          }
					 params = {id:this.getPlanData.id,result:this.selectValue,remark:this.remark}
					 msg = '驳回成功！'
				}
 				this.$http({
			          method: 'post', 
			          apiUrl: '/detection/auditPlan.htm',
			          params:params,
			          isJson:false,
			       }).then(res=>{
			          if(res.code === 0){  
			          	// this.$notify({
						// 	showClose: true,
						// 	message: msg,
						// 	type: 'success',
						// 	title:"成功"
						// })
			          	this.$parent.closeTask()
			          	this.$store.dispatch('getWorkflowList',0).then(res=>{
			          		this.$notify({
			          			showClose:true,
			          			message:'操作成功',
			          			type:'success',
								title:"成功"
			          		})
			          	})
						
			          }else{
//			          	reject(err)
			          }   
			        },)
			       this.$emit('update:auditTaskDialogShow',false)
			}
		},
		computed:{
			auditTaskShow:{
				get(){
					return this.auditTaskDialogShow
				},
				set(){
					
				}
			}
		}
	}
</script>

<style>
	
</style>